package com.sm.healthy.adapter

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.sm.healthy.R
import com.sm.healthy.data.bean.BloodPressureEntity
import com.sm.healthy.data.bean.FetalEntity
import com.sm.healthy.databinding.ItemHistoryDataBinding
import com.sm.healthy.databinding.ItemHistoryFetalDataBinding

/**
 * 历史数据列表
 */
class HistoryFetalListAdapter(
    layoutId: Int = R.layout.item_history_fetal_data,
    list: MutableList<FetalEntity> = arrayListOf()
) : BaseQuickAdapter<FetalEntity, BaseDataBindingHolder<ItemHistoryFetalDataBinding>>(
    layoutId,
    list
) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemHistoryFetalDataBinding>,
        item: FetalEntity
    ) {
        holder.dataBinding?.fetalValue = item

        when {
            item.levelFetalRate <= 60 -> {
                holder.dataBinding?.textView13?.text = "↓"
                holder.dataBinding?.textView13?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.levelFetalRate in 61..89 -> {
                holder.dataBinding?.textView13?.text = ""
            }
            item.levelFetalRate > 90 -> {
                holder.dataBinding?.textView13?.text = "↑"
                holder.dataBinding?.textView13?.setTextColor(Color.parseColor("#de253b"))
            }
        }
    }
}